#ifndef NMFIELD_H_
#define NMFIELD_H_

#include "rectype.h"

namespace opsrc {
	namespace stdf {
		
		template < typename T, int L>
		class NmField
		{
		public:
			NmField();
			NmField(char *p, endian e);
			virtual ~NmField();
			
			T decode(char* buf);
			int getByteCount() const; 
			T getData() const;		
			
			int getTotalByteCount() const;
			
		private:
			T data;
			int len;
			endian en;	
			
					
		};

		// Specialization for short (2 byte integer)
		template < int L>
		class NmField < short, L>
		{
		public:
			NmField();
			NmField(char *p, endian e);
			virtual ~NmField();
			
			short decode(char* buf);
			int getByteCount() const; 
			short getData() const;		
			
			int getTotalByteCount() const;
	
		private:	
			short data;
			int len;
			endian en;			

		};
		
		
		// Specialization for float (4 byte floating point number)
		template < int L>
		class NmField < float, L>
		{
		public:
			NmField();
			NmField(char *p, endian e);
			virtual ~NmField();
			
			float decode(char* buf);
			int getByteCount() const; 
			float getData() const;		
			
			int getTotalByteCount() const;
	
		private:	
			float data;
			int len;
			endian en;			

		};
		
		// Specialization for double (8 byte floating point or double number )
		template < int L>
		class NmField < double, L>
		{
		public:
			NmField();
			NmField(char *p, endian e);
			virtual ~NmField();
			
			double decode(char* buf);
			int getByteCount() const; 
			double getData() const;		
			
			int getTotalByteCount() const;
	
		private:	
			double data;
			int len;
			endian en;			

		};
				
		

	}		// namespace stdf
}			// namespace opsrc

#endif /*NMFIELD_H_*/
